<template>
	<view class="main">
		<view class="user-form">
			<view style="height: 30rpx;"></view>
			<view class="form-item poser dis-row row-box">
				<view class="item-label">姓名</view>
				<view class="item-input">
					<input type="text" v-model="inputForm.realName" class="un-input" placeholder="请输入姓名"/>
				</view>
			</view>
			<view class="form-item poser dis-row row-box">
				<view class="item-label">身份证号</view>
				<view class="item-input">
					<input type="text" v-model="inputForm.cardNo" class="un-input" placeholder="请输入身份证号码"/>
				</view>
			</view>
			<view class="send-button row-box" v-if="status == 0">
				<button type="primary" @click="sendPost">确定</button>
			</view>
		</view>
	</view>
</template>

<script>
import Index from "@/common/index-model.js"	
import fun from "@/common/publicFun.js"	
let index = new Index()
let that = this
export default {
	data() {
		return {
			inputForm:{
				realName:'',
				cardNo:''
			},
			status:0
		}
	},
	methods: {
		getRz() {
			index.getPublicUserMember({},'client/realauth/nameInfo','get',res=>{
				if(res.data.code == 200 && res.data.success){
					console.log(res)
					let arr = res.data.result
					this.status = arr.status
					this.inputForm.realName = arr.realName?arr.realName:''
					this.inputForm.cardNo = arr.cardNo?arr.cardNo:''
				}else{
					this.status = 0
				}
			})
		},
		sendPost(){
			if(!this.inputForm.realName){
				index.show_tips('姓名不能为空')
				return
			}
			if(!fun.checkisIDCard(this.inputForm.cardNo)){
				index.show_tips('请输入正确的身份证号码')
				return
			}
			index.getPublicUserMember(this.inputForm,'/client/realauth/realname','post',res=>{
				if(res.data.code == 200 && res.data.success){
					index.show_tips('您的认证信息提交成功')
					setTimeout(()=>{
						//index.redirectto('./index')
						index.switch_tab('../../pages/user/index')
					},500)
				}else{
					index.show_tips(res.data.message);
					return false
				}
			})
		},
	},
	onLoad() {
		this.getRz()
	}
}
</script>

<style>
@import url("@/static/css/publics.css");
@import url("@/static/css/myeditphone.css");	
</style>